package com.wangxinyuchuan.demo.factory_method;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wangxinyuchuan
 * @date 2023/4/12 10:36 AM
 */
public class IDCardFactory extends Factory {

    private final Map<Integer, String> ownerMap = new HashMap<>();

    private static int serialNo = 100;
    @Override
    protected Product createProduct(String owner) {
        return new IDCard(owner, serialNo++);
    }

    @Override
    protected void registerProduct(Product product) {
        ownerMap.put(serialNo, ((IDCard)product).getOwner());
    }

    public Map<Integer, String> getOwnerMap() {
        return ownerMap;
    }
}
